from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
# 1.导入鼠标操作类
from selenium.webdriver.common.action_chains import ActionChains

driver = webdriver.Firefox()
driver.maximize_window()
driver.get('file:///D:/nsd2404/html/registerA.html')
# 2.创建鼠标操作对象
action = ActionChains(driver)
# 定位用户文本框
username = driver.find_element(By.CSS_SELECTOR, '#userA')
username.send_keys('admin')
# 3.在用户名执行右击
# perform()  执行以上的操作
action.context_click(username).perform()

sleep(3)
# 4.双击
action.double_click(username).perform()
sleep(3)
button = driver.find_element(By.CSS_SELECTOR, 'button')
# 5.移动到元素
action.move_to_element(button).perform()

sleep(3)
driver.quit()